<?php
header("Refresh:1 ;url=./add2.php");
$dish_name=$_REQUEST['dish_name'];
$price=$_REQUEST['price'];
$icon=$_REQUEST['icon'];
$dish_type_id=$_REQUEST['dish_type_id'];

include 'db.php';
$sql="insert into dish(dish_name,price,icon,dish_type_id) values('$dish_name','$price','./img/$icon','$dish_type_id')";
$sqls=$conn->prepare($sql);
$ok=$sqls->execute();

if (isset($dish_name) && empty($dish_name)){
     exit("请输入菜品");
}
if (isset($price) && empty($price)){
    exit("请输入菜品单价");
}
if (isset($icon) && empty($icon)){
    exit("请插入图片");
}
if (isset($dish_type_id) && empty($dish_type_id)){
    exit("请插入菜品类型");
}

if(isset($ok)){
    exit("添加成功");
}else{
    exit("添加失败");
}

// c://xxx.tmp
// ./img/xxx.jpg  copy()